package com.funo.main.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.funo.core.base.BaseDao;
import com.funo.main.dao.UserRoleDao;
import com.funo.main.entities.UserRole;

/**
 * 用户与角色关系接口实现类
 * 
 * @author zhengjs
 *
 */
@Repository
public class UserRoleDaoImpl extends BaseDao<UserRole, String> implements UserRoleDao {

	@Override
	public List<UserRole> getByRole(String id) {
		List<UserRole> list = super.findByHql(
				"from UserRole where user.id = ?", id);
		return list.size() > 0 ? list : null;
	}

	@Override
	public void deleteByHql(UserRole userRole) {
		super.executeHql(
				"delete from UserRole where role.id = ? and user.id = ?",
				new Object[] { userRole.getRole().getId(),
						userRole.getUser().getId() });
	}

}
